package DPT_680;

public class Solution {
	public boolean validPalindrome(String s) {
		int low = 0, high = s.length() - 1;
		while (low < high) {
			char c1 = s.charAt(low);
			char c2 = s.charAt(high);
			if (c1 == c2) {
				low++;
				high--;
			} else {
				boolean leftFlag = true, rightFlag = true;
				for (int i = low, j = high - 1; i < j; i++, j--) {
					if (s.charAt(i) != s.charAt(j)) {
						rightFlag = false;
						break;
					}
				}
				for (int i = low + 1, j = high; i < j; i++, j--) {
					if (s.charAt(i) != s.charAt(j)) {
						leftFlag = false;
						break;
					}
				}
				return leftFlag||rightFlag;

			}
		}
		return true;
	}
}
